package de.cau.apo.problems.unrelatedscheduling;

/**
 * This class represents a job for the unrelated scheduling problem.
 * It just consists of a fixed index and of a fixed sizes, one for each machine.
 * 
 * @author Marius Richter
 *
 */
public class Job {

	// ########### properties ###########
	
	/** the index of this job */
	public final int index;
	/** the sizes of this job */
	public final int[] sizes;
	
	
	// ########### instantiation ###########
	
	/**
	 * Creates a new job object.
	 * @param index the index for this job
	 * @param sizes the sizes for this job on each machine
	 */
	public Job(int index, int[] sizes) {
		this.index = index;
		this.sizes = sizes;
	}
	
	// ########### getter/setter ###########
	
	/**
	 * @return the index of this job
	 */
	public int getIndex() {
		return index;
	}
	
	/**
	 * @param machine the machine for that the size of this job has to be returned
	 * @return the size of this job on the given machine
	 */
	public int getSize(Machine machine) {
		return sizes[machine.getIndex()];
	}
	
	/**
	 * @param machine the machine to that this job shall be assigned
	 * @return true if this job can be assigned to the given machine, false otherwise
	 */
	public boolean isAssignableTo(Machine machine) {
		return getSize(machine) != -1;
	}

	// ########### overriding toString() ###########

	@Override
	public String toString() {
		return "Job [index=" + index + ", sizes=" + sizes + "]";
	}

}
